<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	template="/WEB-INF/templates/template.xhtml"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich"
	>
	<ui:define name="content">
		<ui:include src="/includes/menu.xhtml"></ui:include>
		
	<a4j:outputPanel id="eventpanel" layout="block">
    	<rich:panel style="float:left; width:800px; padding:5px;">
		<h1><h:outputText value="Události" /></h1>
		
		<h:outputLink value="#{request.contextPath}/views/create-event.jsf" rendered="#{loginBean.isLogged()}">Založ novou událost</h:outputLink>		
		
		<a4j:outputPanel id="panel" layout="block">
          <a4j:repeat value="#{eventListBean.events}" var="event" rows="20" id="repeat">
              <rich:panel style="float:left; width:750px; padding:5px;">
                  <f:facet name="header">
                      <h:panelGroup>
                       	<h:panelGrid columns="2">
                       	<h:link includeViewParams="true" outcome="event">
                       	   <h:outputText value="#{event.eventDate} : " />
                           <h:outputText value="#{event.description} " />
                           <f:param name="event" value="#{event.id}"/>
				  		</h:link>
                  		</h:panelGrid>
                  		<h:panelGrid columns="3">
                  			<h:outputText value="Pořádá:" />
                       		<h:outputText value="#{event.webuser.nick}" />
                  		</h:panelGrid>
                      </h:panelGroup>
                  </f:facet>
                  <h:panelGrid columns="1" style="float:right;" rendered="#{eventListBean.admin}">
                      <h:form>
						<h:commandButton value="delete" action="#{eventListBean.deleteEvent(event.id)}" />
					  </h:form>
                  </h:panelGrid>
              </rich:panel>
          </a4j:repeat>
       </a4j:outputPanel>
       </rich:panel>
       </a4j:outputPanel>
	</ui:define>
</ui:composition>